// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Security;

public sealed partial class ApplicationGlobalUserPrivileges
{
	[JsonInclude, JsonPropertyName("manage")]
	public Elastic.Clients.Elasticsearch.Security.ManageUserPrivileges Manage { get; set; }
}

public sealed partial class ApplicationGlobalUserPrivilegesDescriptor : SerializableDescriptor<ApplicationGlobalUserPrivilegesDescriptor>
{
	internal ApplicationGlobalUserPrivilegesDescriptor(Action<ApplicationGlobalUserPrivilegesDescriptor> configure) => configure.Invoke(this);

	public ApplicationGlobalUserPrivilegesDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Security.ManageUserPrivileges ManageValue { get; set; }
	private Elastic.Clients.Elasticsearch.Security.ManageUserPrivilegesDescriptor ManageDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Security.ManageUserPrivilegesDescriptor> ManageDescriptorAction { get; set; }

	public ApplicationGlobalUserPrivilegesDescriptor Manage(Elastic.Clients.Elasticsearch.Security.ManageUserPrivileges manage)
	{
		ManageDescriptor = null;
		ManageDescriptorAction = null;
		ManageValue = manage;
		return Self;
	}

	public ApplicationGlobalUserPrivilegesDescriptor Manage(Elastic.Clients.Elasticsearch.Security.ManageUserPrivilegesDescriptor descriptor)
	{
		ManageValue = null;
		ManageDescriptorAction = null;
		ManageDescriptor = descriptor;
		return Self;
	}

	public ApplicationGlobalUserPrivilegesDescriptor Manage(Action<Elastic.Clients.Elasticsearch.Security.ManageUserPrivilegesDescriptor> configure)
	{
		ManageValue = null;
		ManageDescriptor = null;
		ManageDescriptorAction = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (ManageDescriptor is not null)
		{
			writer.WritePropertyName("manage");
			JsonSerializer.Serialize(writer, ManageDescriptor, options);
		}
		else if (ManageDescriptorAction is not null)
		{
			writer.WritePropertyName("manage");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Security.ManageUserPrivilegesDescriptor(ManageDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("manage");
			JsonSerializer.Serialize(writer, ManageValue, options);
		}

		writer.WriteEndObject();
	}
}